package com.syni.mdd.sjb.common.datatreaure.controller.server;

import com.syni.mdd.sjb.common.component.mybatis.dxshapp.entity.DxshAppIndustry;
import com.syni.mdd.sjb.common.component.utils.common.utils.ResultMapHelper;
import com.syni.mdd.sjb.common.component.utils.feign.service.mdd.sjb.common.tool.VerificationCodeService;
import com.syni.mdd.sjb.common.component.utils.feign.service.mdd.sjb.common.tool.dto.CheckVerificationCodeDto;
import com.syni.mdd.sjb.common.datatreaure.service.BmsUserBusinessService;
import com.syni.mdd.sjb.common.datatreaure.service.DxshAppIndustryService;
import io.seata.spring.annotation.GlobalTransactional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @className BmsCommonController
 * @description TOO
 * @Author cfx
 * @DATE 2019/5/29 9:31
 * @VERSION 1.0
 **/
@RestController
@RequestMapping("/server")
public class ServerController {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Value("${jenkins-build-number:0}")
    private String version;

    @GetMapping("/version")
    public String version(){
        return "当前版本 ： #" + version;
    }

    @Autowired
    BmsUserBusinessService bmsUserBusinessService;

    @Autowired
    VerificationCodeService verificationCodeService;

    @Autowired
    DxshAppIndustryService dxshAppIndustryService;

    @GetMapping("/testRibbon")
    @GlobalTransactional(rollbackFor = Exception.class)
    public Map<String,Object> testRibbon(){
        //String rpc = RestTemplateUtils.getForEntity(RestTemplateUtils.getLoadRestTemplate(),"http://mdd-user/user/apiUser/ribbonTest",new HashMap<>());
        DxshAppIndustry dxshAppIndustry = new DxshAppIndustry();
        dxshAppIndustry.setIndustryName("cccc");
        dxshAppIndustryService.save(dxshAppIndustry);

        CheckVerificationCodeDto checkVerificationCodeDto = new CheckVerificationCodeDto();
        verificationCodeService.checkVerificationCode(checkVerificationCodeDto);
        return ResultMapHelper.success();
    }
}
